<?php

class GalleryController extends Zend_Controller_Action
{

    public function init()
    {
        //设置引用css
        $this->view->headLink()->appendStylesheet($this->view->baseUrl().'/css/gallery.css');
        //设置title
        $this->view->headTitle("玉石图片");
    }

    public function indexAction()
    {
        //设置title
		$this->view->headTitle('经典岫玉雕刻作品鉴赏');
		//设置关键词（seo）
		$this->view->headMeta()->appendName('keywords',"岫玉图片,玉石摆件图片,玉雕图片");
		//设置描述（seo）
		$this->view->headMeta()->appendName('description',"汇集经典岫玉雕刻作品图片鉴赏，按题材划分为人物系列、动物系列、花卉植物系列、山水风景系列、瓶素系列。");
		$config=new Zend_Config_Ini(APPLICATION_PATH."/configs/application.ini",'production');
		$db = Zend_Db::factory($config->resources->db);
		$selecter=$db->select()->from('txy_gallery',array('gallery_id','gallery_title','gallery_url_spell','gallery_logo'))
		->where('gallery_id <=22 and gallery_flag=1')
		->order('gallery_id asc');
		$galleryrlist=$db->fetchAll($selecter);
		$this->view->galleryr=$galleryrlist;
		
		$selected=$db->select()->from('txy_gallery',array('gallery_id','gallery_title','gallery_url_spell','gallery_logo'))
		->where('gallery_id >22 and gallery_id<=54 and gallery_flag=1')
		->order('gallery_id asc');
		$gallerydlist=$db->fetchAll($selected);
		$this->view->galleryd=$gallerydlist;
		
		$selecteh=$db->select()->from('txy_gallery',array('gallery_id','gallery_title','gallery_url_spell','gallery_logo'))
		->where('gallery_id >54 and gallery_id<=74 and gallery_flag=1')
		->order('gallery_id asc');
		$galleryhlist=$db->fetchAll($selecteh);
		$this->view->galleryh=$galleryhlist;
		
		$selectes=$db->select()->from('txy_gallery',array('gallery_id','gallery_title','gallery_url_spell','gallery_logo'))
		->where('gallery_id >74 and gallery_id<=80 and gallery_flag=1')
		->order('gallery_id asc');
		$galleryslist=$db->fetchAll($selectes);
		$this->view->gallerys=$galleryslist;
		
		$selectep=$db->select()->from('txy_gallery',array('gallery_id','gallery_title','gallery_url_spell','gallery_logo'))
		->where('gallery_id >80 and gallery_id<=90 and gallery_flag=1')
		->order('gallery_id asc');
		$galleryplist=$db->fetchAll($selectep);
		$this->view->galleryp=$galleryplist;
		
		$selecten=$db->select()->from('txy_gallery',array('gallery_id','gallery_title','gallery_url_spell','gallery_logo'))
		->where('gallery_id >=91 and gallery_flag=1')
		->order('gallery_id desc');
		$gallerynlist=$db->fetchAll($selecten);
		$this->view->galleryn=$gallerynlist;
    }
    
    public function contentAction(){
    	$galleryId=$this->getRequest()->getParam('id');
		$db_model=new Application_Model_DbTable_Gallery();
		$gallery=$db_model->getGalleryById($galleryId);
		//设置title
		$this->view->headTitle($gallery->gallery_title);
		//设置关键词（seo）
		$this->view->headMeta()->appendName('keywords', $gallery->gallery_key_words);
		//设置描述（seo）
		$this->view->headMeta()->appendName('description',$gallery->gallery_description);
		//文章标题
		$this->view->title=$gallery->gallery_title;
		//创建时间
		$this->view->create_date=$gallery->gallery_create_date;
		//图集内容
		$imgarray=unserialize($gallery->gallery_img);
		unset($imgarray[0]);
		$this->view->imgs=$imgarray;
		//文字描述
		if(null!=$gallery->gallery_text_description&&""!=$gallery->gallery_text_description){
		    $this->view->text_description=$gallery->gallery_text_description;
		}

		//浏览次数
		$count=$gallery->gallery_count_num;
		$this->view->count=$count;
		$count++;
		$db_model->updateCount($galleryId, $count);

		$this->view->sideBar=1;
		//边栏热门文章列表
		$articleModel=new Application_Model_DbTable_Article();
		$this->view->hotArticles=$articleModel->getHotArticle(15);
		//边栏热门商品列表
		$itemsModel=new Application_Model_DbTable_TaobaoItems();
		$this->view->hotItems=$itemsModel->getSidebarHotItems();
		//热门关键词
		$keywordsModel=new Application_Model_DbTable_Keywords();
		$this->view->keyWordsList=$keywordsModel->getHotKeyWords();
    }


}

